package database.utils;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

public class DataSourceUtils {
    //获得c3p0的连接池
    private static ComboPooledDataSource dataSource = new ComboPooledDataSource();

    /**
     * 获得连接池对象
     * @return
     * @throws SQLException
     */
    public static Connection getConnection() throws SQLException {
        return dataSource.getConnection();
    }

    /**
     * 获得c3p0数据源对象
     * @return
     */
    public static DataSource getDataSource(){
        return dataSource;
    }
}
